/**
 * @description AI实验室模块api
 */

import { http } from '../http'

const { get, put, post, formPost, delete: del } = http

// 标注
export const dmpTaskApi = {
  /* 废弃（旧）--------------------------------------------------------------------------- */
  // list: get('/spa/dmp/v1/task'),
  // add: post('/spa/dmp/v1/task'),
  // edit: put('/spa/dmp/v1/task'),
  // del: del(`/spa/dmp/v1/task/:id`),
  // detail: (id: number | string | null) => get(`/spa/dmp/v1/task/${id}`)(),
  // taskBucketData: get('/spa/dmp/v1/task-bucket-data'),
  // taskTag: get('/spa/dmp/v1/task-tag'),
  // taskTagAdd: post('/spa/dmp/v1/task-tag'),
  // taskTagEdit: put('/spa/dmp/v1/task-tag'),
  // taskTagDel: del(`/spa/dmp/v1/task-tag/:id`),
  // taskDataMark: post('/spa/dmp/v1/task-bucket-data/mark'),
  // taskDataMarkInfo: (id: number | string | null) => get(`/spa/dmp/v1/task-bucket-data/${id}`)(),
  // taskProgress: (id: number | string | null) => get(`/spa/dmp/v1/task/progress/${id}`)(),
  // localExport: get(`/spa/dmp/v1/task/local-export`), //本地导出
  // onlineExport: post(`/spa/dmp/v1/task/online-export`), //在线导出
  // onlineExportCancel: post(`/spa/dmp/v1/task/cancelExport`), //取消在线导出任务
  // onlineExportList: get(`/spa/dmp/v1/task/exportList`), //获取在线导出任务列表
  // onlineExportSchedule: get(`/spa/dmp/v1/task/schedule`), //获取在线导出任务的进度
  // onlineExportTaskFailFile: (id: string) => get(`/spa/dmp/v1/task/failFile/${id}`), //获取在线导出失败文件列表
  // onlineExportTaskReset: (id: string) => post(`/spa/dmp/v1/task/exportRetry/${id}`), //在线导出任务失败文件重传
  // getImgStartIndex: get('/spa/dmp/v1/task-bucket-data/index'), //获取图片在任务中的起始索引
  // partImgList: get('/spa/dmp/v1/task-bucket-data/list'), //通过索引获取部分图片列表
  /* 1.3（新）--------------------------------------------------------------------------- */
  list: get('/spa/mark/v1/mark'),
  add: post('/spa/mark/v1/mark'),
  edit: put('/spa/mark/v1/mark'),
  del: del('/spa/mark/v1/mark/:id'),
  /*导出--------------------------------------------------------------------------- */
  //本地导出
  localExport: get(`/spa/mark/v1/mark/local-export`),
  //在线导出
  onlineExport: post(`/spa/mark/v1/mark/online-export`),
  //取消在线导出任务
  onlineExportCancel: post(`/spa/mark/v1/mark/cancelExport`),
  //获取在线导出任务列表
  onlineExportList: get(`/spa/mark/v1/mark/exportList`),
  //获取在线导出失败文件列表
  onlineExportTaskFailFile: (id: string) => get(`/spa/mark/v1/mark/failFile/${id}`),
  //在线导出任务失败文件重传
  onlineExportTaskReset: (id: string) => post(`/spa/mark/v1/task/exportRetry/${id}`),
  /* 分享--------------------------------------------------------------------------- */
  // 分享列表
  getShareList: get('/spa/mark/v1/share-info/:id'),
  // 分享
  share: post('/spa/mark/v1/share-info/4'),
  // 删除分享用户
  removeShareUser: del('/spa/mark/v1/share-info/:id'),
  /* 标签组--------------------------------------------------------------------------- */
  // 标签组-分页列表
  tagGroupList: get('/spa/mark/v1/label-group'),
  // 标签组-列表
  tagGroupAllList: get('/spa/mark/v1/label-groups'),
  // 标签组-新增
  tagGroupAdd: post('/spa/mark/v1/label-group'),
  // 标签组-编辑
  tagGroupEdit: put('/spa/mark/v1/label-group'),
  // 标签组-详情
  tagGroupDetail: get('/spa/mark/v1/label-group/:id'),
  // 标签组-删除
  tagGroupDel: del('/spa/mark/v1/label-group/:id'),
  /* 标签--------------------------------------------------------------------------- */
  // 标签-列表
  tagList: get('/spa/mark/v1/label-group-info'),
  // 标签-列表
  tagAdd: post('/spa/mark/v1/label-group-info'),
  // 标签-列表
  tagEdit: put('/spa/mark/v1/label-group-info'),
  // 标签-删除
  tagDel: del('/spa/mark/v1/label-group-info/:id'),
  // 标签-详情
  tagDetail: get('/spa/mark/v1/label-group-info/:id'),
  // 导入数据
  importData: post('/spa/mark/v1/bucket/import'),
  // 导入列表
  importDataList: get('/spa/mark/v1/mark/inputList'),
  // 删除单个
  removeImportData: post('/spa/mark/v1/mark/remove/input'),
  // 删除多个或者全删
  removeImportDataList: post('/spa/mark/v1/mark/removeInputList')
}

// 算法测试
export const algoTestApi = {
  list: get('/spa/task/v1/task'),
  add: post('/spa/task/v1/task'),
  del: del(`/spa/task/v1/task/:id`),
  getDownloadUrl: (id: string) => get(`/spa/task/v1/task/download/${id}`),
  recordList: get('/spa/task/v1/taskRecord'),
  recordDetail: (id: string) => get(`/spa/task/v1/taskRecord/${id}`), //运行记录
  getRecordDownloadUrl: (id: string) => get(`/spa/task/v1/task/downloadTaskRecordById/${id}`), //下载运行记录
  detail: (id: string) => get(`/spa/task/v1/task/${id}`),
  run: post('/spa/task/v1/task/run'),
  uploadCode: formPost('/spa/task/v1/task/uploadCode'),
  codeDetail: get('/spa/task/v1/task/getCodeDetails'),
  editCode: put('/spa/task/v1/task/updateCodeDetails'),
  stopTask: put('/spa/task/v1/task/stop'),
  startTask: put('/spa/task/v1/task/start'),
  // 分享列表
  getShareList: get('/spa/task/v1/share-info/:id'),
  // 分享
  share: post('/spa/task/v1/share-info'),
  // 删除分享用户
  removeShareUser: del('/spa/task/v1/share-info/:id')
}

// 模型训练
export const modelTrainingApi = {
  list: get('/spa/train/v1/task'), //分页查询
  add: post('/spa/train/v1/task'), //新增
  deploy: post('/spa/train/v1/task/deploy'), //部署
  info: get(`/spa/train/v1/task/:id`), // 根据id查询详情
  forecast: get('/spa/train/v1/task/predict/:id'), //分页查询
  del: del(`/spa/train/v1/task/:id`), //删除
  //导出本地任务
  localExport: get('/spa/train/v1/task/local-export/:id'),
  //本地导出列表
  localExportList: get('/spa/train/v1/task/local-export-list'),
  //取消本地导出
  localExportCancel: del('/spa/train/v1/task/local-cancel-export/:exportId'),
  //清除本地导出
  localExportClear: del('/spa/train/v1/task/local-clean-export'),
  //下载本地导出
  downloadExport: get('/spa/train/v1/task/local-download-export/:exportId'),
  //导出本地任务
  onlineExport: post('/spa/train/v1/task/online-export'),
  //在线导出列表
  onlineExportList: get('/spa/train/v1/task/export-list'),
  //取消在线导出
  onlineExportCancel: del('/spa/train/v1/task/online-cancel-export/:exportId'),
  //清除在线导出
  onlineExportClear: del('/spa/train/v1/task/online-clean-export'),
  //在线导出失败文件列表
  onlineExportFailedList: get('/spa/train/v1/task/fail-file/:exportId'),
  //在线导出失败文件重传
  onlineExportTaskReset: post('/spa/train/v1/task/export-retry/:exportId'),
  // 分享列表
  getShareList: get('/spa/train/v1/share-info/:id'),
  // 分享
  share: post('/spa/train/v1/share-info'),
  // 删除分享用户
  removeShareUser: del('/spa/train/v1/share-info/:id')
}

/* 算法开发 */
export const algoDevApi = {
  list: get('/spa/cleaner/v1/algorithm'),
  reset: post('/spa/cleaner/v1/reset-code/:id'),
  notebookList: get('/spa/cleaner/v1/notebook'),
  addNotebook: post('/spa/cleaner/v1/notebook'),
  editNotebook: put('/spa/cleaner/v1/notebook'),
  detailNotebook: get('/spa/cleaner/v1/notebook/:id'),
  delNotebook: del('/spa/cleaner/v1/notebook/:id'),
  startNotebook: post('/spa/cleaner/v1/start/:id'),
  stopNotebook: post('/spa/cleaner/v1/stop/:id'),
  getNotebookShareList: get('/spa/cleaner/v1/share-info/:id'),
  shareNotebook: post('/spa/cleaner/v1/share-info/7'),
  removeNotebookShareUser: del('/spa/cleaner/v1/share-info/:id'),
  saveAlgo: post('/spa/cleaner/v1/save-algorithm'),
  defaultAlgoList: get('/spa/cleaner/v1/algorithm'),
  customAlgoList: get('/spa/cleaner/v1/custom-algorithm'),
  saveAlgorithm: post('/spa/cleaner/v1/algorithm'),
  detailAlgorithm: get('/spa/cleaner/v1/algorithm/:id'),
  editAlgorithm: put('/spa/cleaner/v1/algorithm'),
  delAlgorithm: del('/spa/cleaner/v1/algorithm/:id'),
  getAlgorithmShareList: get('/spa/cleaner/v1/share-info/:id'),
  shareAlgorithm: post('/spa/cleaner/v1/share-info/9'),
  removeAlgorithmShareUser: del('/spa/cleaner/v1/share-info/:id'),
  checkNotebookStatus: get('/spa/cleaner/v1/notebook/check-status/:id'),
  checkAlgorithmStatus: get('/spa/cleaner/v1/algorithm/check-status/:id'),
  copyAlgo: post('/spa/cleaner/v1/algorithm/copy/:id'),
  downFile: get('/spa/cleaner/v1/notebook/local-download-export/:id'),
  getExportList: get('/spa/cleaner/v1/notebook/local-export-list'),
  export: get('/spa/cleaner/v1/notebook/local-export/:id'),
  cancelExport: del('/spa/cleaner/v1/notebook/local-cancel-export/:id'),
  cancelAllExport: del('/spa/cleaner/v1/notebook/local-clean-export')
}

/* 数据清洗 */
export const dataCleaningApi = {
  list: get('/spa/cleaner/v1/cleaner-task'),
  cleanerTasks: get('/spa/cleaner/v1/cleaner-tasks'),
  detail: get('/spa/cleaner/v1/cleaner-task/:id'),
  add: post('/spa/cleaner/v1/cleaner-task'),
  edit: put('/spa/cleaner/v1/cleaner-task'),
  del: del('/spa/cleaner/v1/cleaner-task/:id'),
  delBatch: del('/spa/cleaner/v1/cleaner-task'),
  onlineExport: post('/spa/cleaner/v1/cleaner-task/onlineExport'),
  onlineExportCancel: post(`/spa/cleaner/v1/cleaner-task/cancelExport`),
  onlineExportList: get('/spa/cleaner/v1/cleaner-task/exportList'),
  onlineExportFailedList: get(`/spa/cleaner/v1/task/failFile/:id`),
  onlineExportTaskReset: post(`/spa/cleaner/v1/task/exportRetry/:id`),
  localExport: get('/spa/cleaner/v1/cleaner-task/localExport'),
  localExportList: get('/spa/cleaner/v1/cleaner-task/localExportList'),
  localExportCancel: post('/spa/cleaner/v1/cleaner-task/localCancelExport'),
  downLocalExport: get('/spa/cleaner/v1/cleaner-task/doLocalExport'),
  approximateTaskResult: get('/spa/cleaner/v1/cleaner-task-result/approximate'),
  dimTaskResult: get('/spa/cleaner/v1/cleaner-task-result/definition'),
  detailBatchDel: del('/spa/cleaner/v1/cleaner-task-result'),
  dataBucketTree: get('/spa/data/v1/bucket/user/clean/list'),
  searchBucketList: get('/spa/data/v1/bucket/user/clean/name'),
  //获取本地导出任务的文件id地址
  downloadExport: get(`/spa/cleaner/v1/cleaner-task/download`),
  getShareList: get('/spa/cleaner/v1/share-info/:id'),
  share: post('/spa/cleaner/v1/share-info/3'),
  removeShareUser: del('/spa/cleaner/v1/share-info/:id')
}

/* 文本标注任务标签 */
export const textLabelTagApi = {
  entityList: get('/spa/mark/v1/mark-task-labels/entity'),
  relationList: get('/spa/mark/v1/mark-task-labels/rel'),
  getMarkTaskLabels: get('/spa/mark/v1/mark-task-labels'),
  add: post('/spa/mark/v1/mark-task-label'),
  addRelation: post('/spa/mark/v1/mark-task-label/triples'),
  edit: put('/spa/mark/v1/mark-task-label'),
  editRelation: put('/spa/mark/v1/mark-task-label/triples'),
  del: del('/spa/mark/v1/mark-task-label/:id'),
  top: put('/spa/mark/v1/mark-task-label/top')
}

/* 文本标注 */
export const textLabelApi = {
  save: post('/spa/mark/v1/mark-task-result'),
  delText: del('/spa/mark/v1/markInfo/remove/:id'),
  delAllText: del('/spa/mark/v1/markInfo/removes'),
  getLabelResult: get('/spa/mark/v1/mark-reslt/info'),
  getTaskTextList: get('/spa/mark/v1/mark-task-info'),
  getMarkTaskProgress: get('/spa/mark/v1/mark/progress/:id'),
  getTaskDetail: get('/spa/mark/v1/mark/:id'),
  getCurrentTextInfo: get('/spa/mark/v1/mark-info/next'),
  getUserHistory: get('/spa/mark/v1/markInfo/page/:id'),
  resetUserHistory: get('/spa/mark/v1/markInfo/pageReset'),
  recoverText: put('/spa/mark/v1/markInfo/makeUse/:id')
}

/* 图片标注 */
export const imgLabelApi = {
  save: post('/spa/mark/v1/mark-task-result'),
  /** 标记为无效数据 */
  void: del('/spa/mark/v1/markInfo/remove/:id'),
  /** 撤销无效数据 */
  recoverVoid: put('/spa/mark/v1/markInfo/makeUse/:id'),
  /** 标记为难例 */
  difficultExample: put('/spa/mark/v1/markInfo/makeHard/:id'),
  /** 撤销难例 */
  recoverDifficultExample: put('/spa/mark/v1/markInfo/removeHard/:id'),

  delAllText: del('/spa/mark/v1/markInfo/removes'),
  getLabelResult: get('/spa/mark/v1/mark-reslt/img/info'),
  getTaskTextList: get('/spa/mark/v1/mark-task-info'),
  getMarkTaskProgress: get('/spa/mark/v1/mark/progress/:id'),
  getTaskDetail: get('/spa/mark/v1/mark/:id'),
  getCurrentTextInfo: get('/spa/mark/v1/mark-info/next'),
  getUserHistory: get('/spa/mark/v1/markInfo/page/:id'),
  resetUserHistory: get('/spa/mark/v1/markInfo/pageReset')
}

export const mirrorManageApi = {
  uploadFile: post('/spa/cleaner/v1/image/upload-file'),
  editMirror: put('/spa/cleaner/v1/image'),
  addMirror: post('/spa/cleaner/v1/image'),
  customMirrorList: get('/spa/cleaner/v1/custom-image'),
  getRepositoryOptions: get('/spa/cleaner/v1/repositorys'),
  getRepositoryList: get('/spa/cleaner/v1/repository'),
  addRepository: post('/spa/cleaner/v1/repository'),
  editRepository: put('/spa/cleaner/v1/repository'),
  getDefaultMirrorList: get('/spa/cleaner/v1/default-image'),
  getBuildLog: get(`/spa/cleaner/v1/image/build-log/:id`),
  delMirror: del(`/spa/cleaner/v1/image/:id`),
  delRepository: del('/spa/cleaner/v1/repository/:id'),
  getShareList: get('/spa/cleaner/v1/share-info/:id'),
  share: post('/spa/cleaner/v1/share-info/8'),
  removeShareUser: del('/spa/cleaner/v1/share-info/:id'),
  imageCommon: get('/spa/cleaner/v1/image-common'),
  imageAll: get('/spa/cleaner/v1/image-all')
}

// 应用
export const appApi = {
  list: get('/spa/warehouse/v1/app'), // 应用列表
  add: post('/spa/warehouse/v1/app'), // 新增应用
  edit: put('/spa/warehouse/v1/app'), // 编辑应用
  del: (id: string) => del(`/spa/warehouse/v1/app/${id}`), // 编辑应用
  editData: (id: string) => get(`/spa/warehouse/v1/app/getAppUpdateById/${id}`), // 编辑回显数据
  detail: (id: string) => get(`/spa/warehouse/v1/app/${id}`), // 应用详情
  algoList: get('/spa/algorithm/v1/algorithm-service/control/operate-method'), // 算法服务列表
  uploadFingerprint: formPost('/spa/warehouse/v1/app/uploadFile'), // 上传指纹文件
  getLicenseFileUrl: (id: string) => get(`/spa/warehouse/v1/app/downloadLicense/${id}`), // 获取license文件地址
  getSdkFileUrl: (id: string) => get(`/spa/warehouse/v1/app/downloadSdk/${id}`), // 获取sdk文件地址
  getSerialDeviceCode: (id: string) => get(`/spa/warehouse/v1/app/deviceCodeList/${id}`), // 获取设备码
  // 获取技术文档url
  getDownloadDocumentUrl: get('/spa/warehouse/v1/app/downloadDocument/:operateId')
}

// 审核记录
export const auditListApi = {
  list: get('/spa/warehouse/v1/audit/pageForAuditAppBySelf'), //获取审核记录
  appDetail: (id: string) => get(`/spa/warehouse/v1/audit/getByAppIdBySelf/${id}`), //应用详情
  downloadFiles: (id: string) => get(`/spa/warehouse/v1/audit/downloadFinger/${id}`) //获取指纹文件minio地址
  // downloadFiles: get(`/warehouse/v1/audit/downloadFinger`) //获取指纹文件minio地址
}

// 调用记录
export const callRecordsApi = {
  getAlVersionList: get('/spa/algorithm/v1/client/al-version'), //算法、版本级联接口-用户侧
  getAppList: get('/spa/warehouse/v1/client/app'), //应用下拉框-用户侧
  list: get('/spa/callrecord/v1/call-records/user/ip'), //获取ip记录
  queryCallRecords: get(`/spa/callrecord/v1/call-records/user`) //调用记录查询（用户端）
}

// 应用概览
export const overviewApi = {
  getOverview: get(`/spa/warehouse/v1/app/overview`)
}

// 模型评估
export const modelEvaluationApi = {
  list: get('/spa/train/v1/atp-task/page'),
  add: post('/spa/train/v1/atp-task'), // 新增模型
  modelBaseList: get('/spa/data/v1/model-base/atp-task/list'), // 公开模型管理查询
  modelFavoriteList: get('/spa/data/v1/commom-model/favorite'), // 我收藏的模型管理查询
  getNormDetailsOptions: get('/spa/train/v1/normDetails'), // 指标查询
  uploadDir: get('/spa/train/v1/atp-task/upload-dir'), // 代码文件上传获取文件前缀
  stopTask: put('/spa/train/v1/atp-task/stop'), // 停止任务
  startTask: put('/spa/train/v1/atp-task/start'), // 启动任务
  del: del(`/spa/train/v1/atp-task/:id`), // 删除
  share: post('/spa/train/v1/share-info/6'), // 分享
  removeShareUser: del('/spa/train/v1/share-info/:id'), // 删除分享
  getShareList: get('/spa/train/v1/atp-task/share-info/:id'), // 获取分享列表
  getDetail: get('/spa/train/v1/atp-task'), // 编辑时查询详情
  edit: put('/spa/train/v1/atp-task'), // 编辑
  rename: put('/spa/train/v1/atp-task/rename'), // 重命名
  getDetailResult: get('/spa/train/v1/atp-task/result'), // 查询详情
  getTaskFile: get('/spa/train/v1/atp-task/download'), // 获取文件下载地址/预览文件内容
  export: get('/spa/train/v1/atp-task/export') // 导出报告
}
